home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / vbimex.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  6.0 KB  |  219 lines

  1. VERSION 2.00
  2. Begin Form VBIMEX 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "VisData Imp/Exp"
  6.    ClientHeight    =   5295
  7.    ClientLeft      =   2175
  8.    ClientTop       =   1935
  9.    ClientWidth     =   4725
  10.    ControlBox      =   0   'False
  11.    Height          =   5700
  12.    Left            =   2115
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   5295
  17.    ScaleWidth      =   4725
  18.    Top             =   1590
  19.    Width           =   4845
  20.    Begin CommandButton cCloseBtn 
  21.       Cancel          =   -1  'True
  22.       Caption         =   "&Close"
  23.       Height          =   375
  24.       Left            =   2400
  25.       TabIndex        =   4
  26.       Top             =   120
  27.       Width           =   2055
  28.    End
  29.    Begin CommandButton cExportSQL 
  30.       Caption         =   "Export &SQL Results"
  31.       Enabled         =   0   'False
  32.       Height          =   375
  33.       Left            =   2400
  34.       TabIndex        =   0
  35.       Top             =   600
  36.       Width           =   2055
  37.    End
  38.    Begin CommandButton cImportBtn 
  39.       Caption         =   "&Import"
  40.       Height          =   375
  41.       Left            =   240
  42.       TabIndex        =   1
  43.       Top             =   120
  44.       Width           =   2055
  45.    End
  46.    Begin ListBox cTables 
  47.       Height          =   4125
  48.       Left            =   120
  49.       MultiSelect     =   2  'Extended
  50.       TabIndex        =   3
  51.       Tag             =   "OLS"
  52.       Top             =   1080
  53.       Width           =   4470
  54.    End
  55.    Begin CommandButton cExportBtn 
  56.       Caption         =   "&Export Table(s)"
  57.       Enabled         =   0   'False
  58.       Height          =   375
  59.       Left            =   240
  60.       TabIndex        =   2
  61.       Top             =   600
  62.       Width           =   2055
  63.    End
  64.    Begin CommonDialog CMD1 
  65.       Left            =   3840
  66.       Top             =   120
  67.    End
  68. Sub cCloseBtn_Click ()
  69.   Unload Me
  70. End Sub
  71. Sub cExportBtn_Click ()
  72.   On Error GoTo ExpErr
  73.   For i = 0 To cTables.ListCount - 1
  74.     If cTables.Selected(i) Then
  75.       DataType.Caption = "Export '" & cTables.List(i) & "'"
  76.       DataType.Show MODAL
  77.       cTables.Selected(i) = False
  78.       If gDataType <> DT_NONE Then
  79.         If gDataType <> DT_SQLDB Then
  80.           SetCommDlg
  81.           CMD1.Action = 2
  82.           If Len(CMD1.Filename) > 0 Then
  83.             If gDataType <> DT_TABDELIM Then
  84.               Export (cTables.List(i)), (CMD1.Filename)
  85.             Else
  86.               ExportTabDelim (cTables.List(i)), (CMD1.Filename)
  87.             End If
  88.           End If
  89.         Else
  90.           Export (cTables.List(i)), NULL_STR
  91.         End If
  92.       End If
  93.     End If
  94.   Next
  95.   cExportBtn.Enabled = False
  96.   Exit Sub
  97. ExpErr:
  98.   If Err = 32755 Then Exit Sub
  99.   ShowError
  100.   Exit Sub
  101. End Sub
  102. Sub cExportSQL_Click ()
  103.   On Error GoTo SQLExpErr
  104.   DataType.Caption = "Export '" & cTables.List(i) & "'"
  105.   DataType.Show MODAL
  106.   If gDataType <> DT_NONE Then
  107.     If gDataType <> DT_SQLDB Then
  108.       SetCommDlg
  109.       CMD1.Action = 2
  110.       If Len(CMD1.Filename) > 0 Then
  111.         If gDataType <> DT_TABDELIM Then
  112.           Export NULL_STR, (CMD1.Filename)
  113.         Else
  114.           ExportTabDelim NULL_STR, (CMD1.Filename)
  115.         End If
  116.       End If
  117.     Else
  118.       Export NULL_STR, NULL_STR
  119.     End If
  120.   End If
  121.   Exit Sub
  122. SQLExpErr:
  123.   If Err = 32755 Then Exit Sub
  124.   ShowError
  125.   Exit Sub
  126. End Sub
  127. Sub cImportBtn_Click ()
  128.   On Error GoTo ImpErr
  129.   DataType.Caption = "Import"
  130.   DataType.Show MODAL
  131.   If gDataType = DT_NONE Then Exit Sub
  132.   If gDataType <> DT_SQLDB Then
  133.     SetCommDlg
  134.     CMD1.Action = 1
  135.     If Len(CMD1.Filename) > 0 Then
  136.       If gDataType = DT_MSACCESS Or gDataType = DT_BTRIEVE Then
  137.         If gDataType = DT_MSACCESS Then
  138.           Set gImpDB = OpenDatabase(CMD1.Filename)
  139.         Else
  140.           Set gImpDB = OpenDatabase(CMD1.Filename, 0, 0, "Btrieve")
  141.         End If
  142.         If gImpDB Is Nothing Then Exit Sub
  143.         ImpTbls.Label1 = ImpTbls.Label1 + gImpDB.Name
  144.         ImpTbls.Show MODAL
  145.       Else
  146.         Import (CMD1.Filename)
  147.         While Len(CMD1.Filename) > 0
  148.           CMD1.Filename = NULL_STR
  149.           CMD1.Action = 1
  150.           Import (CMD1.Filename)
  151.         Wend
  152.       End If
  153.     End If
  154.   Else
  155.     Set gImpDB = OpenDatabase("", 0, 0, "odbc;")
  156.     If gImpDB Is Nothing Then Exit Sub
  157.     ImpTbls.Label1 = ImpTbls.Label1 + gImpDB.Name
  158.     ImpTbls.Show MODAL
  159.   End If
  160.   Exit Sub
  161. ImpErr:
  162.   If Err = 32755 Then Exit Sub
  163.   ShowError
  164.   Exit Sub
  165. End Sub
  166. Sub cTables_Click ()
  167.   cExportBtn.Enabled = True
  168. End Sub
  169. Sub cTables_DblClick ()
  170.   Call cExportBtn_Click
  171. End Sub
  172. Sub Form_Load ()
  173.    Set gDB = gCurrentDB
  174.    If UCase(Mid(fSQL.cSQLStatement, 1, 7)) = "SELECT " Then
  175.      cExportSQL.Enabled = True
  176.    End If
  177.    IMEXRefreshTables
  178.    MsgBar "", False
  179. End Sub
  180. Sub Form_Paint ()
  181.   Outlines Me
  182. End Sub
  183. Sub Form_Resize ()
  184.   If WindowState <> 2 Then
  185.     cTables.Width = Width - 340
  186.     Call Form_Paint
  187.     Refresh
  188.   End If
  189. End Sub
  190. Sub Form_Unload (Cancel As Integer)
  191.   Unload DataType
  192. End Sub
  193. Sub SetCommDlg ()
  194.    CMD1.DialogTitle = "Select File"
  195.    Select Case gDataType
  196.      Case DT_MSACCESS
  197.        CMD1.Filter = "Microsoft Access (*.mdb)|*.mdb|All Files (*.*)|*.*"
  198.        CMD1.DialogTitle = "Select Microsoft Access Database"
  199.      Case DT_PARADOX
  200.        CMD1.Filter = "Paradox (*.db)|*.db"
  201.      Case DT_FOXPRO25
  202.        CMD1.Filter = "FoxPro 2.5 (*.dbf)|*.dbf"
  203.      Case DT_FOXPRO20
  204.        CMD1.Filter = "FoxPro 2.0 (*.dbf)|*.dbf"
  205.      Case DT_DBASEIV
  206.        CMD1.Filter = "dBASE IV (*.dbf)|*.dbf"
  207.      Case DT_DBASEIII
  208.        CMD1.Filter = "dBASE III (*.dbf)|*.dbf"
  209.      Case DT_BTRIEVE
  210.        CMD1.Filter = "Btrieve (FILE.DDF)|FILE.DDF"
  211.      Case DT_TABDELIM
  212.        CMD1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
  213.        CMD1.DialogTitle = "Select Text File"
  214.    End Select
  215.    CMD1.FilterIndex = 1
  216.    CMD1.Filename = ""
  217.    CMD1.CancelError = True
  218. End Sub
  219.